<?php
namespace app\websocket\controller;

class Index
{
    public function open($server, $request)
    {
        echo 'websocket-index-open' . PHP_EOL;
    }

    public function message($server, $frame)
    {
        echo ($frame->data);
        echo PHP_EOL;
        
        echo 'websocket-index-message' . PHP_EOL;
        $server->push($frame->fd, 'websocket-index-message');
    }

    public function close($server, $fd)
    {
        echo 'websocket-index-close' . PHP_EOL;
    }
}
